import * as React from 'react';
import * as PropTypes from 'prop-types';
import FormInfo from '@/pages/routes/table/FormInfo';
import moment from 'moment';
import { getDepartList } from '@/pages/routes/table/equ-table/service';
import { message } from 'antd';
import { ValueObject } from '@/pages/routes/table/interface';

export interface FormDetailProps {}

export interface FormDetailState {
  loading: boolean;
  initialValue: ValueObject | null;
}

class FormDetail extends React.Component<FormDetailProps, FormDetailState> {
  public static propTypes = {};
  public static defaultProps = {};
  public state: FormDetailState = {
    loading: false,
    initialValue: null,
  };

  componentDidMount() {}

  render() {
    const value = {
      name: 'junjun',
      type: 1,
      area: -1,
      startDate: moment('2021-11-14'),
      endDate: moment(),
      ts: [
        { id: '-1638161955315', ownNet: '', dbh: '', description: '哈哈哈哈', checked: true },
        { id: '-1638161917769', ownNet: '', dbh: '', description: '没有人', checked: true },
        { id: '-1638161915587', ownNet: '', dbh: '', description: '一个也不能少', checked: true },
      ],
      hf: [
        { id: '-1638161955315', ownNet: '', dbh: '', description: '哈哈哈哈', checked: true },
        { id: '-1638161917769', ownNet: '', dbh: '', description: '没有人', checked: true },
        { id: '-1638161915587', ownNet: '', dbh: '', description: '一个也不能少', checked: true },
      ],
      scdd: '株洲车载有限公司，株洲市路虎环境卫生管理处',
      gwyx: '株洲车载有限公司，株洲市路虎环境卫生管理处',
      mark: '株洲车载有限公司，株洲市路虎环境卫生管理处',
      bmzz: [],
    };
    return (
      <div>
        <div>
          <FormInfo isEdit initialValue={value} />
        </div>
      </div>
    );
  }

  private async loadData() {
    this.setState({ loading: true });
    try {
      const { msg, data, code } = await getDepartList();
      if (code === -1) {
        this.setState({
          loading: false,
        });
        message.error(msg);
        return;
      }
      this.setState({
        loading: false,
        departList: data,
      });
    } catch (e) {
      console.error(e);
      message.error('获取人员组组织信息失败');
      this.setState({ loading: false });
    }
  }
}

export default FormDetail;
